package com.hanyi.mvc.contorller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
public class RedirectContorller {
    @RequestMapping("/redirect")
    public String redirect(){
        return "redirect:/index.jsp";
    }

    @RequestMapping("/api")
    public void api(HttpServletResponse response){
        System.out.println("api");
        try {
            response.sendRedirect("index.jsp");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @RequestMapping("/info") // 重定向访问web-info下的资源
    public String info(){
        System.out.println("info");
       return "redirect:/hello";
    }
}
